<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>录像播放</title>
	<style type="text/css">
		body,table{font-size:12px; margin:2; overflow:hidden;}
		.select1{
			background: #fdfcf5; margin: -3px -3px -3px -3px;
			width:530px;
		}
	</style>
	<script src="__PUBLIC__/assets/bootstrap/js/jquery-1.11.1.min.js"></script>



</head>
<body>
<div style="width: 100%;margin: auto;padding: 0;">
        <div style="margin: auto;width: 550px;">
			<div style="width: 100%;margin: auto;">
				<!--<object id='snd_chrome' type="audio/x-wav" width="100%" height="80">
					<param name="autostart" value="true" />
					<param name="controller" value="true" />
				</object>-->
				<bgsound id='snd_ie' src="" loop=-1></loop>
				<video  id='snd_chrome'  controls autoplay="true" style="width: 530px;">

				</video>
			</div>
			<div>

				<table border="0" cellspacing="1" cellpadding="3"
					   style="font-size:12px; text-align:center; background:#ccc; width:98%;">

					<tr>
						<td  colspan="6" height="25" bgcolor="#e8f2fd" valign="middle">&nbsp;
							<img id="imgLast" onClick="Last_OneOK();" style="cursor:hand" alt="前一条录像"
								 src="/Public/assets/images/tu_music_1.gif" width="54" height="18" border="0">
							<img id="imgNext" onClick="Next_OneOK();" style="cursor:hand" alt="后一条录像"
								 src="/Public/assets/images/tu_music_2.gif" width="56" height="18" border="0">
						</td>
					</tr>
					<tr bgcolor="#eaeaea">
						<td width="10%" nowrap='nowrap'>通道</td>
							<td width="12%" nowrap='nowrap'>主叫</td>
							<td width="12%" nowrap='nowrap'>被叫</td>
							<td width="12%" nowrap='nowrap'>录音号码</td>
							<td width="12%" nowrap='nowrap'>方向</td>
							<td width="42%" nowrap='nowrap'>开始时间</td>

					</tr>
					<foreach name="rows" item="list" key="k">
						<if condition="$list.localfilename neq ''">
						 <tr name='tr_info' id='tr_info_{$k}' style='display:none;background:#fff;'>
						   <td>{$list.n_channelid}</td>
						   <td>{$list.v_caller}</td>
						   <td>{$list.v_called}</td>
						   <td>{$list.v_ext}</td>
						   <td>{$list.n_calldirection}</td>
						   <td>{$list.d_starttime}</td>
						 </tr>
						</if>
						<if condition="$list.localfilename neq '' && $list.remotefilename neq ''">
						 <tr name='tr_info' id='tr_info_{$k+1}' style='display:none;background:#fff;'>
						   <td>{$list.n_channelid}</td>
						   <td>{$list.v_caller}</td>
						   <td>{$list.v_called}</td>
						   <td>{$list.v_ext}</td>
						   <td>{$list.n_calldirection}</td>
						   <td>{$list.d_starttime}</td>
						 </tr>
						</if>
						<if condition="$list.localfilename eq '' && $list.remotefilename neq ''">
						 <tr name='tr_info' id='tr_info_{$k}' style='display:none;background:#fff;'>
						   <td>{$list.n_channelid}</td>
						   <td>{$list.v_caller}</td>
						   <td>{$list.v_called}</td>
						   <td>{$list.v_ext}</td>
						   <td>{$list.n_calldirection}</td>
						   <td>{$list.d_starttime}</td>
						 </tr>
						</if>  
				   </foreach>
					<tr>
						<td colspan="6" height="20" bgcolor="F2F6FB">&nbsp;播放列表</td>
					</tr>
					<tr>
						<td colspan="6">
							<select name="select" size='10' class='select1' id='SongList' onclick='play()'>
								<foreach name="rows" item="vlist" key="k">
									<if condition="$vlist.localfilename neq ''">
									<option value="{$vlist.localurl}"> 
										{$vlist.localfilename}
									</option>
									</if>
									<if condition="$vlist.remotefilename != ''">
									<option value="{$vlist.remoteurl}"> 
										{$vlist.remotefilename}
									</option>
									</if>
								  </foreach>
							</select>
						</td>
					</tr>
				</table>

			</div>



		</div>
</div>

</body>
<script type="text/javascript">
	var TotalSongs;
	var timer=""
	var MSIE = navigator.userAgent.indexOf("MSIE");//判断浏览器类型
	 
	var tr_last="";	//上一首播放的曲目
	//播放歌曲
	function play(){
	
		var SongList =document.getElementById("SongList");
		var x=SongList.selectedIndex;
		var y=document.getElementById("SongList").options;
		//alert("索引: " + y[x].index + " is " + y[x].text);
		
		if(SongList.options[x].value < 0){
			alert('请选择你要播放的曲目!');
		}else{
			var url = SongList.options[x].value //SongList.find("option:selected").val();//播放歌曲的路径
			 
			//var mname = SongList.text;//播放歌曲的名称
			if(tr_last!=""){
				//如果有刚播放完的上一首，则将其相应的录音信息隐藏
				document.getElementById(tr_last).style.display = 'none'
				//$(tr_last).css('display','none');
			}
			else{
			    document.getElementById("tr_info_0").style.display = ''
				//$("#tr_info_0").css('display','');
			}

			tr_last="tr_info_"+y[x].index//SongList.prop('selectedIndex')
			//$(tr_last).css('display','');
			document.getElementById(tr_last).style.display = ''
			//根据不同的浏览器控制播放器
			//IE
			if(MSIE >0){
				var snd_ie = document.getElementById('snd_ie');
				snd_ie.src = url 
			}else{
				//chrome
				var snd_chrome = document.getElementById('snd_chrome');
				snd_chrome.src = url
			} 
			
			showTLab();
		}
	}

	//控制按钮 上一首
	function Last_OneOK(){
		var SongList =document.getElementById("SongList");
		var TotalSongs = SongList.options.length;
		var x=SongList.selectedIndex;
		var y=document.getElementById("SongList").options;
		if((x > 0) && (x < TotalSongs)){
		        var sindex = x - 1
				SongList[sindex].selected = true;
			//$('#SongList option').eq(SongList.prop('selectedIndex') - 1).prop('selected','selected')
			play();
		}
	}

	//控制按钮 下一首
	function Next_OneOK(){
	    var SongList =document.getElementById("SongList");
		var TotalSongs = SongList.options.length
		var x=SongList.selectedIndex;
		var y=document.getElementById("SongList").options;
	 
		 
		if(x >= 0){
			if(x < TotalSongs - 1){
				//SongList.options[SongList.prop('selectedIndex') + 1].selected = true;
				var sindex = x + 1
				SongList[sindex].selected = true;
				//$('#SongList').find("option:eq("+sindex+")").prop('selected','selected');
				//alert($('#SongList').find("option:eq("+sindex+")").val())
				play();
			}else{
			    SongList[0].selected = true;
				//$('#SongList option:first').prop('selected', 'selected');
				play();
			}
		}
	}

	//检查是否播放完毕，是则播放下一首；
	function showTLab(){
		var snd_chrome =  document.getElementById('snd_chrome');
		if(snd_chrome.ended){
			Next_OneOK()
		}
		timer=setTimeout("showTLab()", 1000);
	}


</script>
<script type="text/javascript">
	var myTo =document.getElementById("SongList");
	var TotalSongs = SongList.options.length;
	if(TotalSongs > 0){
		//播放列表大于0
		if(TotalSongs == 1){
			//只有一首歌，不显示上一首下一首按钮
			//$("#imgLast").css('display','none');
			//$("#imgNext").css('display','none');
		}
		//myTo.css('display','block');
		myTo.style.display = 'block'
		SongList[0].selected = true;
		//$('#SongList option:first').attr('selected','selected')
	}else{
		myTo.style.display = 'none'
		//myTo.css('display','none');
	}

	//试听单条录音时，页面加载完毕后，直接选中用户的父页面点击的记录。并显示录音相关信息
	function t(){
		if($("playFirst").value!="" && $("#SongList option").length>0){
			for(var i=0;i<$('#SongList option').length;i++){
				if($("#playFirst").value==$('#SongList option').get(i).text){
					myTo.val($("#playFirst").val());
				}
			}
			try{
			}catch(e){alert(e.description)}
		}
	}
	//t();
	play();//页面加载完毕，自动开始播放
</script>
</html>
